package tdh.xt.common.utils;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;

/**
 * @package com.xt.util
 * @description url解码工具类
 * @author Ricardo
 * @date 2021/5/10 2:43
 * @copyright (c) 2021,南京通达海科技股份有限公司 All Rights Reserved.
 * @version 1.0
 * Modification History:
 * Date                  Author      Version     Description
 * ------------------------------------------------------------------
 * 2021/5/10 2:43       Ricardo       1.0    url解码工具类
 */
public class UrlUtil {

    /**
     * @description 私有化构造方法，防止误初始化工具类
     * @author RicarAN
     * @date 2021/5/13 13:45
     * @version 1.0
     */
    private UrlUtil(){}

    /**
     * @param encode 编码后的字符串
     * @return java.lang.String 解码后的字符串
     * @description 解码url，前端编码两次，后端解码两次
     * @author RicarAN
     * @date 2021/5/10 2:43
     * @version 1.0
     */
    public static String URLDecode(String encode) {
        String result = "";
        try {
            result = URLDecoder.decode(URLDecoder.decode(encode, "UTF-8"), "UTF-8");
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return result;
    }
}
